<template>
    <BasicTable ref="tableRef" :params="params" :columns="columns" :memory="true" :query="query" @select-change="onSelectChange">
        <template #form>
            <a-form-item label="状态" name="status">
                <a-select v-model:value="params.status" placeholder="请选择用户状态">
                    <a-select-option :value="0">正常用户</a-select-option>
                    <a-select-option :value="1">黑名单</a-select-option>
                </a-select>
            </a-form-item>
            <a-form-item label="微信昵称" name="name">
                <a-input v-model:value="params.name" placeholder="请输入微信昵称" />
            </a-form-item>
        </template>
        <template #table="{ body }">
            <template v-if="body.column.key === 'avatar'">
                <a-image :width="50" :src="body.record.avatar" />
            </template>
            <template v-if="body.column.key === 'status'">
                <a-tag v-if="body.record.status === 0" color="blue">正常用户</a-tag>
                <a-tag v-else color="red">黑名单</a-tag>
            </template>
            <template v-if="body.column.key === 'createDate'">
                {{ parseTime(body.record.createDate) }}
            </template>
        </template>
    </BasicTable>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { BasicTable } from '@iframe/tools/components'
import { query } from '/@/api/Lease/User'
const tableRef = ref()
const params = reactive({})
const select = reactive({
    selectList: []
})
const columns = [
    {
        title: '微信头像',
        dataIndex: 'avatar',
        key: 'avatar',
        align: 'center',
        width: 120
    },
    {
        title: '微信昵称',
        dataIndex: 'nicename',
        key: 'nicename'
    },
    {
        title: '用户状态',
        dataIndex: 'status',
        key: 'status',
        align: 'center',
        width: 120
    },
    {
        title: '创建时间',
        dataIndex: 'createDate',
        key: 'createDate',
        align: 'center',
        width: 200
    }
]
const onSelectChange = (selectedRowKeys, selectedRows) => {
    select.selectList = selectedRows
}
const getSelectList = () => {
    return select.selectList
}
const setSelectKeys = keys => {
    tableRef.value.setSelectedKeys(keys)
}
defineExpose({ getSelectList, setSelectKeys })
</script>
